<template>
  <a-locale-provider :locale="locale">
    <div id="app">
      <router-view/>
    </div>
  </a-locale-provider>
</template>
<script>
    import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
    import enquireScreen from '@/utils/device'

    export default {
        data() {
            return {
                locale: zhCN,
            }
        },
        created() {
            let that = this
            enquireScreen(deviceType => {
                // tablet
                if (deviceType === 0) {
                    that.$store.commit('TOGGLE_DEVICE', 'mobile')
                    that.$store.dispatch('setSidebar', false)
                }
                // mobile
                else if (deviceType === 1) {
                    that.$store.commit('TOGGLE_DEVICE', 'mobile')
                    that.$store.dispatch('setSidebar', false)
                } else {
                    that.$store.commit('TOGGLE_DEVICE', 'desktop')
                    that.$store.dispatch('setSidebar', true)
                }

            })
        },
        methods: {
            isMobile() {
                let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
                return flag;
            }
        },
        mounted() {
          /*  if (this.isMobile()) {
                this.$router.replace('/phone/index');
            } /!*else {
                alert("pc端");
                this.$router.replace('/pc_index');
            }*!/*/
        }
    }
</script>
<style>
  #app {
    height: 100%;
  }
</style>